package com.kira.solo.schedule.domain

import com.kira.solo.schedule.list.CaseListUiState
import com.kira.solo.schedule.list.CaseUiState
import com.kira.solo.schedule.list.FullCaseRepo
import com.kira.solo.schedule.list.uiState
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

/**
 * 所有列表
 * @packageName com.kira.solo.schedule.domain
 * @date 2024/1/25 8:46
 * @author zhanglei
 */
class FullCasesUseCase @Inject constructor(private val repo: FullCaseRepo) {
    operator fun invoke(): Flow<CaseListUiState> {
        return flow {
            emit(CaseListUiState(repo.queryCase().map { it.uiState }))
        }
    }

    operator fun get(id: Long): CaseUiState? {
        return repo[id]?.uiState
    }
}